<%@ page contentType="text/html;charset=UTF-8" %>

<html>
<head>
	<title>信息推荐管理查询</title>
	 <%@ include file="/common/meta.jsp" %>
	<%@ include file="/common/import.jsp" %>
	<script type="text/javascript">
	var sortCodeStr = "";
	var sortMap = {};
	sortMap["t_zl_info"]="专利信息";
	sortMap["t_shebei_info"]="设备信息";
	sortMap["t_labora_info"]="实验室信息";
	
		$(function(){
			for(var k in sortMap){
				sortCodeStr+=k+",";
			}
			sortCodeStr=sortCodeStr.substring(0,sortCodeStr.length-1);
			$('#sortList').datagrid({
				title:'信息推荐列表',
				iconCls:'icon-ok',
				url:'${ctx}/info/admin/list-all!data.action?sortCodeStr='+sortCodeStr+'&f='+new Date().getTime(),
				striped: true,
				collapsible:false,				
				fitColumns: true,
				pagination:true,
				singleSelect:true,
				rownumbers:true,
				remoteSort: false,
				pageList:[10,15,20,30],
				idField:'sortId',
				columns:[[
					{field:'infoTitle',title:'信息标题',width:300},
					{field:'sortCode',title:'信息类型',width:70,
						formatter:function(val){
							return sortMap[val];
						}
					},
					{field:'createTime',title:'创建时间',width:100},
					{field:'createUser',title:'发布人',width:100},
					{field:'status',title:'状态',width:60,
						formatter:function(value){
							if(value=="1") return "暂存";
							if(value=="2") return "发布中";
							if(value=="3") return "已撤销";
						}
					},
					{field:'isTop',title:'是否推荐|最新推荐时间',width:120,align:'center',
						formatter:function(value,row){
							if(value=="T") return "<span style='color:red'>是</span>|"+row.isTopTime;
							else return "否";
						}},
					{field:'infoId',title:'操作',width:100,
						formatter:function(value,rowData){
						    var str ="";
							if(rowData.status=='2'){
								if(rowData.isTop!="T"){
									 str += "<a href='javascript:void(0);' onclick=\"toTopInfo('"+rowData.sortCode+"','"+rowData.infoId+"','"+rowData.infoTitle+"','T')\">推荐为最新</a>";
								}
								if(rowData.isTop=="T"){
									 str += "<a href='javascript:void(0);' onclick=\"toTopInfo('"+rowData.sortCode+"','"+rowData.infoId+"','"+rowData.infoTitle+"','F')\">撤销推荐</a>";
								}
							}
							return str;
						}
					}
				]]
			});
		});
			
		// 刷新列表
		function reload(){
			$('#sortList').datagrid('reload');
		}
	

		function toTopInfo(sortCode,infoId,infoTitle,isTop){
			var ts = "";
			if("T"==isTop)ts="您确认要推荐信息【"+infoTitle+"】吗？";
			if("F"==isTop)ts="您确认撤销所推荐的信息【"+infoTitle+"】吗？";
			if(infoId && confirm(ts)){
				$.ajax({
					   type:'get',
					   url:"${ctx}/info/admin/isTop.action?sortCode="+sortCode+"&infoId="+infoId+"&isTop="+isTop,
					   dataType:'json',
					   success: function(myData){
						   alert(myData.msg);
						   reload();
					  }
				});	
			}
		}
		
		//新的查询功能
		function searchUserNew(){	
			$('#sortList').datagrid('options').pageNumber=parseInt("1"); 
	    	var queryParams = $('#sortList').datagrid('options').queryParams;	       
	        queryParams.infoTitle = $('#infoTitle').val();
	        var options = $('#sortList').datagrid('getPager').data("pagination").options;  
	        options.pageNumber=1;  
	        options.total=0;  
	        options.pageSize=10; 
	        $('#sortList').datagrid("reload");
		}
		
		function clearSearch(){					
		    $('#infoTitle').val('');
		}  
       	
		
	</script>
</head>
<body>
	<table class="planel-body">
			<tr>
				<td>信息标题</td>
				<td>
					<input id="infoTitle" name="infoTitle" maxlength="50" value=""/>
				</td>
				
				<td>
					<a class="easyui-linkbutton" iconCls="icon-search"
						onclick="searchUserNew();">查询</a>
					<a class="easyui-linkbutton" iconCls="" onclick="clearSearch();">清空</a>
				</td>
			</tr>
		</table>
		
	<!-- 应用列表 -->
	<table id="sortList"></table>
	
	<div id="orgDeptWin" class="easyui-window" title="信息审核" style="padding:5px;float:left;top:10px;" iconCls="icon-search" closed="true" minimizable="false" maximizable="false" maximized="true" collapsible="false">
   	 <iframe frameborder="0" id="orgDeptFrame" height="100%" width="100%" scrolling="No" frameborder="0" ></iframe>
    </div>
</body>
</html>